﻿using CRM.Admin.Contracts.Contract.Customer;
using CRM.Admin.Contracts.Dto.Customer;
using CRM.Admin.Contracts.Model.Customer;
using KingsSharp.Common;
using KingsSharp.Common.Data;
using KingsSharp.Core;
using KingsSharp.Core.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CRM.Admin.Services.Service.Customer
{
    public class AscriptionService : ServiceBase, IAscriptionService
    {
        private IRepository<Ascription, Guid> AscriptionRepository;

        public AscriptionService(IRepository<Ascription, Guid> _AscriptionRepository)
            :base(_AscriptionRepository.UnitOfWork)
        {
            AscriptionRepository = _AscriptionRepository;
        }

        public IQueryable<Ascription> Item
        {
            get
            {
                return AscriptionRepository.Entities;
            }
        }

        public OperationResult Insert(params AscriptionDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = AscriptionRepository.Insert(dtos);
            return result;
        }

        public OperationResult Update(params AscriptionDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = AscriptionRepository.Update(dtos);
            return result;
        }

        public OperationResult Delete(params Guid[] ids)
        {
            ids.CheckNotNull("dtos");
            int delcount = AscriptionRepository.Delete(a => ids.Contains(a.Id));
            return new OperationResult(OperationResultType.Success, "删除成功");
        }
    }
}
